58
Beginner’s Guide to Code Algorithms
58
STEP 18
The first step is to identify the corners of the polyomino and store them in an
array. This array is called putnumberpresent below. The entire row is scanned for
a candidate number (putnumber) and if the column contains exactly two cells that
could be a home for this number, this column is remembered along with the two rows
that could potentially be the two vertices of the polyomino.
‘*** algorithm to detect a golden polyomino
‘ Check each column and build putnumberpresent
For putnumber = 1 To 9
For i = 1 To 9
PCol(i) = ““
Next i
ColCount = 0
For i = 1 To 9
ColumnCount = 0
putnumberpresent(1, i) = ““
lastcorner = ““
For j = 1 To 9
If sbox(j, i) = ““ Then
If findincantbelist(putnumber, j, i) = 0 Then
lastcorner = lastcorner & j
putnumberpresent(j, i) = lastcorner
ColumnCount = ColumnCount + 1
End If
End If
Next j
If ColumnCount = 2 Then
ColCount = ColCount + 1
PCol(ColCount) = i
Else
putnumberpresent(1, i) = “*”
End If
Next i
:
:
STEP 19
The second step is to scan the putnumberpresent array to get them in an array of
rows, count the number of unique rows and the nodes.
:
‘* collecting all the row numbers in putnumberpresent
nodecount = 0
RowCount = 0
For i = 1 To 9
PRow(i) = ““
Next i
For i = 1 To 9